using Service;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace WindowsClient
{
    public partial class MainForm : Form
    {

        private static Person.PersonForm instancePersonForm;
        private static Document.DocumentForm instanceDocumentForm;
        private static Organization.OrganizationForm instanceOrganizationForm;

        // Lock synchronization object 
        private static object syncLock = new object();
        
        public MainForm()
        {
            InitializeComponent();
            this.statusStrip1.Renderer = new CustomStatusStripRenderer();
            this.toolStrip1.Renderer = new CustomStatusStripRenderer();
            this.menuStrip1.Renderer = new CustomStatusStripRenderer();
        }



        private void MainForm_Load(object sender, EventArgs e)
        {
            // TODO: This line of code loads data into the 'personDataSet.Person' table. You can move, or remove it, as needed.
            PartyService partyService = new PartyService();
            this.WindowState = FormWindowState.Maximized;

        }

   

        private void toolStripButton1_Click(object sender, EventArgs e)
        {
            if (instancePersonForm == null)
            {
                lock (syncLock)
                {
                    if (instancePersonForm == null)
                    {

                        instancePersonForm = new Person.PersonForm();
                        instancePersonForm.MdiParent = this;
                        instancePersonForm.WindowState = FormWindowState.Maximized; 
                        instancePersonForm.Show();
                    }
                }
            }

            instancePersonForm.BringToFront();
        }

        private void toolStripButton2_Click(object sender, EventArgs e)
        {

            if (instanceDocumentForm == null)
            {
                lock (syncLock)
                {
                    if (instanceDocumentForm == null)
                    {

                        instanceDocumentForm = new Document.DocumentForm();
                        instanceDocumentForm.MdiParent = this;
                        instanceDocumentForm.WindowState = FormWindowState.Maximized; 
                        instanceDocumentForm.Show();
                    }
                }
            }

         
            instanceDocumentForm.BringToFront();

        }

        private void tsbtnOrganization_Click(object sender, EventArgs e)
        {
            if (instanceOrganizationForm == null)
            {
                lock (syncLock)
                    {

                        instanceOrganizationForm = new Organization.OrganizationForm();
                        instanceOrganizationForm.MdiParent = this;
                        instanceOrganizationForm.WindowState = FormWindowState.Maximized;
                        instanceOrganizationForm.Show();
                    }
            }
            instanceOrganizationForm.BringToFront();
        }

    }
}